package com.day0929.try_catch;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Text {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        try{
            System.out.println("请输入被除数：");
            int num1 = in.nextInt();
            System.out.println("请输入除数：");
            int num2 = in.nextInt();
            int shang = num1/num2;
            System.out.println("商：" + shang);
        } catch (InputMismatchException e){//输入异常
            System.out.println("输入异常");
        } catch (Exception e){//   exception  表示任何异常都会处理    是所有异常的父类
            e.printStackTrace();//打印异常错误的堆栈信息
            System.out.println(e.getMessage());//打印异常信息
            System.out.println("程序异常");
        }finally {
            System.out.println("是否发生异常，皆执行");
        }
    }
}
